;
(function(factory) {
	factory(jQuery, window, document);
}(function($, window, document) {

	$(function() {
		var layer = function() {};
		layui.use('layer', function() {
			layer = layui.layer;
		});
		funOp.init();
	});

	var funOp = {
		init: function() {
			// funOp.getCaptcha();
			$('#login').click(function() {
				funOp.login();
			});
		},

		login: function() {
			var username = $('#username').val();
			var password = $('#password').val();
			var s = 'select * from user where username = ? and password = ? and del_flag = 0 ;';
			var obj = {
				sql: $.fn.commUtil.getSqlStr(s, [username, password])
			}

			$.newAjax({
				url: $.fn.commUtil.constant.baseUrl + '/dealSql',
				data: JSON.stringify(obj),
				success: function(res) {
					// console.info(res)
					if (res.code != 0) {
						layer.alert(res.msg);
						return;
					}
					if (res.data.length === 0) {
						layer.alert('用户密码不匹配');
						return;
					}
					window.sessionStorage.setItem("loginUser",JSON.stringify(res.data[0]))
					window.location.href = "index.html"
				}
			});
		},


	};

}));
